const ADD = 'add'
const REDUCE = 'reduce'

export function counter(state=0,action){
   switch (action.type) {
      case ADD:
        return state+1
      case REDUCE:
        return state-1
     default:
        return 10
       break;
   }
}

export function addNum(){
    return {type: ADD}
}

export function reduceNum(){
    return {type: REDUCE}
}

export function addNumAsync(){
    return dispatch=>{
        setTimeout(()=>{
           dispatch(addNum())
        }, 2000)
    }
}

export function reduceNumAsync(){
    return dispatch=>{
        setTimeout(()=>{
           dispatch(reduceNum())
        }, 2000)
    }
}